export default {
    //存储数据
    state: { token:'' },

    actions: {},

    //调用方法
    mutations: {
       /* SET_TOKEN: (state, token) => {
            state.token = token
            sessionStorage.setItem("token", token)
        },*/

        setToken(state, token){
            state.token = token;
            sessionStorage.setItem("token", token)
        },

        getToken(state){
            //如果缓存中存在token，则直接获取；如果没有则从state中获取token
            state.token = state.token || sessionStorage.getItem("token")
        },

        clearToken(){
          state.token=''
          sessionStorage.removeItem("token");
        }
    }


}


